package com.dpp.mapper;

import com.dpp.entity.Transactions;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Mapper
public interface TransactionsMapper {
    @Insert("INSERT INTO transactions( openid, take_openid,number, coinsbefore, coinsafter, moneybefore, moneyafter, transactiondate, transactiontype, fee)" +
            " values(#{openid},#{takeOpenid},#{number},#{coinsBefore},#{CoinsAfter},#{moneyBefore},#{moneyAfter},#{date},#{transactionType},#{fee})")
    void insert(String openid, String takeOpenid,Long number, Integer coinsBefore, Integer CoinsAfter, Integer moneyBefore, Integer moneyAfter, Date date, String transactionType, Integer fee);

    @Select("SELECT * FROM transactions WHERE take_openid=#{openid} order by TransactionDate DESC")
    List<Transactions> selectByTakeOpenId(String openid);
}
